package com.jiangruan.javaPro.service;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaPro.Constants;
import com.jiangruan.javaPro.bean.HotVideo;
import com.jiangruan.javaPro.bean.HotVideoCommon;
import com.jiangruan.javaPro.net.HttpUtils;

import java.util.List;

/**
 * @author:冷风诉离歌
 * @desc:
 * @datetime: 2021/12/15 19:44
 */

public class HotVideoService {
    /**
     *该方法用于获取热门数据，并将热门数据返回
     */

    public List<HotVideo> getHotVideo(){
        String url = Constants.TRIP_URL
                + "?key="
                + Constants.TRIP_KEY
                + "&type=hot_video"
                + "&size = 10";
        String result = HttpUtils.get(url);
        System.out.println(result);

        HotVideoCommon videoCommon = JSONObject.parseObject(result, HotVideoCommon.class);

        return videoCommon.result;
    }
}
